From ce87813af668f77f19509b0b69d6ee9b529cc231 Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Tue, 5 Jan 1999 21:27:07 +0000 Subject: [PATCH] Stuff I did last night while watching TV --- gdk-pixbuf/ChangeLog | 0 gdk-pixbuf/Makefile.am | 21 ++++++++++++++++++--- gdk-pixbuf/gdk-pixbuf.h | 1 + gdk-pixbuf/io-png.c | 38 +++++++++++++++++++++++++++++++++----- 4 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 gdk-pixbuf/ChangeLog diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gdk-pixbuf/Makefile.am b/gdk-pixbuf/Makefile.am index 54b3938877..acb7979975 100644 --- a/gdk-pixbuf/Makefile.am +++ b/gdk-pixbuf/Makefile.am @@ -1,7 +1,22 @@ -_SOURCES = \ +lib_LTLIBRARIES = \ + libgdk-pixbuf.la \ + libpixbuf-png.la + +# +# The GdkPixBuf library +# +libgdk_pixbufincludedir = $(includedir)/gdk-pixbuf + +libgdk_pixbuf_la_SOURCES = \ gdk-pixbuf.c \ gdk-pixbuf-io.c - -_HEADERS = \ + +libgdk_pixbufinclude_HEADERS = \ gdk-pixbuf.h + +# +# The PNG plugin. +# +libpixbuf_png_la_SOURCES = \ + io-png.c \ No newline at end of file diff --git a/gdk-pixbuf/gdk-pixbuf.h b/gdk-pixbuf/gdk-pixbuf.h index 6c5e8f8fb6..02132d8d86 100644 --- a/gdk-pixbuf/gdk-pixbuf.h +++ b/gdk-pixbuf/gdk-pixbuf.h @@ -1,6 +1,7 @@ #ifndef _GDK_PIXBUF_H_ #define _GDK_PIXBUF_H_ +#include #include typedef struct { diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c index 18f661ce05..414ef45e76 100644 --- a/gdk-pixbuf/io-png.c +++ b/gdk-pixbuf/io-png.c @@ -2,7 +2,6 @@ * io-png.c: GdkPixBuf image loader for PNG files. * * Author: - * Rasterman (raster@redhat.com). * Miguel de Icaza (miguel@gnu.org) * */ @@ -19,6 +18,8 @@ image_load (FILE *f); png_structp png; png_infop info_ptr, end_info; int width, height, depth, color_type, interlace_type; + int have_alpha, number_passes; + art_u8 *data; g_return_val_if_fail (filename != NULL, NULL); @@ -50,13 +51,40 @@ image_load (FILE *f); if (color_type == color_type == PNG_COLOR_TYPE_PALETTE) png_set_expand (png); - + + /* + * Strip 16 bit information to 8 bit + */ png_set_strip_16 (png); + + /* + * Extract multiple pixels with bit depths 1, 2 and 4 from a single + * byte into separate bytes + */ png_set_packing (png); - if (png_get_valid (png, info_ptr, PNG_INFO_tRNS)) - png_set_expand (png); + /* + * Makes the PNG file to be rendered into RGB or RGBA + * modes (no matter of the bit depth nor the image + * mode + */ + png_set_expand (png); + + /* + * Simplify loading by always having 4 bytes + */ png_set_filler (png, 0xff, PNG_FILLER_AFTER); - /* FIXME finish this */ + if (color_type & PNG_COLOR_MASK_ALPHA) + have_alpha = 1 + else + have_alpha = 0; + + data = art_alloc (width * height * (3 + have_alpha)); + if (!data){ + png_destroy_read_struct (&png, &info_ptr, &end_info); + return NULL; + } + + number_passes = png_set_interlace_handling (png); } -- 2.30.2